/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedbean.SOP;
import java.util.ArrayList;
import java.util.Collection;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import merlion.common.util.exception.NotExistException;
import merlion.crm.slcm.entity.Address;
import merlion.crm.slcm.entity.Customer;
import merlion.crm.slcm.entity.SalesLead;
import merlion.crm.slcm.entity.MemberDiscountGroup;
import merlion.crm.slcm.entity.OrderDiscountGroup;
import merlion.crm.slcm.session.SLCSessionBeanLocal;
import merlion.crm.sopm.entity.ItemLine;
import merlion.crm.sopm.entity.RequestForQuotation;
import merlion.crm.sopm.session.SOPSessionBeanLocal;

/**
 *
 * @author Zhou Hong
 */
@ManagedBean (name = "rfqManagerBean")
@SessionScoped

public class RequestForQuotationManagerBean {
    
    @EJB
    private SOPSessionBeanLocal sOPSessionBean;
    @EJB
    private SLCSessionBeanLocal sLCSessionBean;
    private RequestForQuotation requestForQuotation;
    private String currency;
    private String comments;
    private Address address;
    
    public RequestForQuotationManagerBean() {
        this.requestForQuotation = new RequestForQuotation();  
    }
    
    public void persistRequestForQuotation() {
        RequestForQuotation saveMsg = sOPSessionBean.saveRequestForQuotation(getRequestForQuotation());
        if(saveMsg != null){
            System.out.println("request for quotation saved successfully");
        } else {
            System.out.println("request for quotation saved unsuccessfully");
        }
    }
    
    public String confirmRequestForQuotation() {
        try{
           requestForQuotation.setSalesLead(sLCSessionBean.getClientByClientId(requestForQuotation.getSalesLead().getClientId()));
        }
        catch(NotExistException ex){
            
        }
        return "confirmRequestForQuotation";
    }


    /**
     * @return the currency
     */
    public String getCurrency() {
        return currency;
    }

    /**
     * @param currency the currency to set
     */
    public void setCurrency(String currency) {
        this.currency = currency;
    }

    /**
     * @return the comments
     */
    public String getComments() {
        return comments;
    }

    /**
     * @param comments the comments to set
     */
    public void setComments(String comments) {
        this.comments = comments;
    }

    /**
     * @return the address
     */
    public Address getAddress() {
        return address;
    }

    /**
     * @param address the address to set
     */
    public void setAddress(Address address) {
        this.address = address;
    }

    /**
     * @return the requestForQuotation
     */
    public RequestForQuotation getRequestForQuotation() {
        return requestForQuotation;
    }

    /**
     * @param requestForQuotation the requestForQuotation to set
     */
    public void setRequestForQuotation(RequestForQuotation requestForQuotation) {
        this.requestForQuotation = requestForQuotation;
    }
    
}
